/**
 *Copyright(C) 2019 by DefaultCompany
 *All rights reserved.
 *FileName:     BaseUI.cs
 *Author:       why
 *Version:      1.0
 *UnityVersion：2017.2.2f1
 *Date:         2019-05-10
 *Description:  UI窗体父类
 *定义UI窗体的父类
 * 有四个生命周期
 * 1.Display显示状态
 * 2.Hiding隐藏状态
 * 3.ReDisplay再显示状态
 * 4.Freeze冻结状态 就是弹出窗体后面的窗体冻结
 *History:
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
namespace HHHFramework
{
    [System.Serializable]
    //窗体类型
    public class UIType
    {

        public int SiblingIndex =100;
            //this.transform.SetSiblingIndex
        /// <summary>
        /// UI窗体(位置)类型
        /// </summary>
        public UIFormType type = UIFormType.Normal;

        /// <summary>
        ///UI窗体显示类型
        /// </summary>
        public UIFormShowMode mode = UIFormShowMode.Normal;

    }
    #region 系统枚举类型
    /// <summary>
    /// UI窗体(位置)类型
    /// </summary>
    public enum UIFormType
    {
        /// <summary>
        /// 第一层
        /// </summary>//一般是全屏窗体
        Normal,
        /// <summary>
        /// 固定窗体
        /// </summary>//一般是固定不动的 某一方向的一组图标
        Fixed,
        /// <summary>
        /// 提示框 在最上层
        /// </summary>
        Tips,
    }

    /// <summary>
    /// UI窗体的显示类型
    /// </summary>
    public enum UIFormShowMode
    {
        /// <summary>
        /// 普通  
        /// </summary>//同一层级叠加
        Normal,
        /// <summary>
        /// 反向切换 冻结上一个 反向切换类型 显示当前的并进行入栈  关闭的时候自动显示站内的上一个  应该是用作返回按钮
        /// </summary>//按照相反方向切换过去 原路弹回来
        ReverseChange,
        /// <summary>
        /// 隐藏其他 
        /// </summary>//覆盖掉其他窗口
        HideOther
    }


    #endregion 
    public class BaseUI : MonoBehaviour, IRegister
    {
        public UIType currentUIType  = new UIType();
       
        #region 窗体的6种状态(生命周期)
        /// <summary>
        /// 初始化
        /// </summary>
        public virtual void IniForm()
        {

           Register();
        }

        /// <summary>
        /// 显示状态
        /// </summary>
        public virtual void ActiveTrue()
        {
            gameObject.SetActive(true);

        }

        /// <summary>
        /// 隐藏状态
        /// </summary>
        public virtual void ActiveFalse()
        {
            gameObject.SetActive(false);
        }

        /// <summary>
        /// 重新显示状态
        /// </summary>
        public virtual void ReActiveTrue()
        {
            gameObject.SetActive(true);

        }

        /// <summary>
        /// 冻结状态   不能再进行点击的状态
        /// </summary>
        public virtual void Freeze()
        {
            gameObject.SetActive(true);
        }
        /// <summary>
        /// 将物体放回到对象池中时执行
        /// </summary>
        public virtual void DestoryUIForm(){

            UnRegister();

        }
        #endregion


        /// <summary>
        /// 打开UI窗体
        /// </summary>
        /// <param name="UIName"></param>
        protected void OpenUI(string UIName)
        {
            GUIManager.Instance.ShowUI(UIName);
        }

        /// <summary>
        /// 关闭UI窗体
        /// </summary>
        protected void CloseUI()
        {
            string UIName;
            UIName = GetType().Name;
            GUIManager.Instance.CloseUI(UIName);

        }

        /// <summary>
        /// 显示语言 多语言切换
        /// </summary>
        /// <param name="id"></param>
        protected void SwitchLanguage(string id)
        {
            
            //return LauguageMgr.instance.ShowText(id);
        }

        public virtual void Register()
        {
            
        }

        public virtual void UnRegister()
        {
        }
    }
}